package com.zjsd.sqeybusiness.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zjsd.sqeybusiness.domain.AgencyChat;
import com.zjsd.sqeybusiness.service.IAgencyChatService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 代理商在线留言Controller
 *
 * @author Zheng
 * @date 2020-11-05
 */
@Api("厂家留言")
@RestController
@RequestMapping("/jph/agencyChat")
public class AgencyChatController extends BaseController
{
    @Autowired
    private IAgencyChatService agencyChatService;

    /**
     * 查询代理商在线留言列表
     */
    @ApiOperation("查询代理商在线留言列表")
    @PreAuthorize("@ss.hasPermi('jph:agencyChat:list')")
    @GetMapping("/list")
    public TableDataInfo list(AgencyChat agencyChat)
    {
        startPage();
        List<AgencyChat> list = agencyChatService.selectAgencyChatList(agencyChat);
        return getDataTable(list);
    }

    /**
     * 导出代理商在线留言列表
     */
    @PreAuthorize("@ss.hasPermi('jph:agencyChat:export')")
    //@Log(title = "代理商在线留言", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AgencyChat agencyChat)
    {
        List<AgencyChat> list = agencyChatService.selectAgencyChatList(agencyChat);
        ExcelUtil<AgencyChat> util = new ExcelUtil<AgencyChat>(AgencyChat.class);
        return util.exportExcel(list, "agencyChat");
    }

    /**
     * 获取代理商在线留言详细信息
     */
    @PreAuthorize("@ss.hasPermi('jph:agencyChat:query')")
    @GetMapping(value = "/{chatId}")
    public AjaxResult getInfo(@PathVariable("chatId") Long chatId)
    {
        return AjaxResult.success(agencyChatService.selectAgencyChatById(chatId));
    }

    /**
     * 新增代理商在线留言
     */
    @PreAuthorize("@ss.hasPermi('jph:agencyChat:add')")
    //@Log(title = "代理商在线留言", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AgencyChat agencyChat)
    {
        return toAjax(agencyChatService.insertAgencyChat(agencyChat));
    }

    /**
     * 修改代理商在线留言
     */
    @PreAuthorize("@ss.hasPermi('jph:agencyChat:edit')")
    //@Log(title = "代理商在线留言", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AgencyChat agencyChat)
    {
        return toAjax(agencyChatService.updateAgencyChat(agencyChat));
    }

    /**
     * 删除代理商在线留言
     */
    @PreAuthorize("@ss.hasPermi('jph:agencyChat:remove')")
    //@Log(title = "代理商在线留言", businessType = BusinessType.DELETE)
	@DeleteMapping("/{chatIds}")
    public AjaxResult remove(@PathVariable Long[] chatIds)
    {
        return toAjax(agencyChatService.deleteAgencyChatByIds(chatIds));
    }
}
